package com.gs.service.impl;

import com.github.pagehelper.PageHelper;
import com.gs.entity.User;
import com.gs.mapper.UserMapper;
import com.gs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ProjectName: springbootmybits
 * @Package: com.gs.service.impl
 * @Description: java类作用描述
 * @Author: Administrator
 * @CreateDate: 2018/5/18 15:29
 * @UpdateUser: Administrator
 * @UpdateDate: 2018/5/18 15:29
 * @UpdateRemark: The modified content
 * @Version: 1.0
 **/

@Service(value = "userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;//这里会报错，但是并不会影响


    @Override
    public int addUser(User user) {
        int a =userMapper.insert(user);
        System.out.println(8/0);
        return a;
    }

    @Override
    public List<User> findAllUser(int pageNum, int pageSize) {
        //将参数传给这个方法就可以实现物理分页了，非常简单。
        PageHelper.startPage(pageNum, pageSize);
        List<User>  list = userMapper.selectAllUser();
        return list;
    }

    @Override
    public List<User> getUserInfo() {
        List<User>  list = userMapper.getUserInfo();
        return list;
    }

    @Override
    public int insertOrUpdateUsers(List<User> users) {
        return userMapper.insertOrUpdateUsers(users);
    }
}
